#!/usr/bin/env python
# encoding: utf-8
# @author: Lin Han
# @contact: voldemort22@126.com
# @file: remove_rps_file_from_01.py
# @time: 2021/4/12 10:01
# @desc:
import pymongo

from .views.configs import *
from .utils.md5_tools import getFileMd5
from .utils.mongo_tools import total_number_generator_only_for_old_clamp, total_number_generator, retrieve_all_mongo_values
from .utils.oss.oss import upload_file_to_oss
from .utils.utils import read_json

myclient = pymongo.MongoClient(MONGO_URL)
mydb = myclient["do_center"]
history_clamp = mydb["history_clamp"]

cursor = history_clamp.find({})

rps_list = []
for i in cursor:
    if i["name"].split(".")[0][-3:] == "RPS":
        rps_list.append(i)

rps_number_list = [j["number"] for j in rps_list]

for k in rps_number_list:
    history_clamp.delete_many({"number": k})